package com.sx.pipeline.ui.report

import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.blankj.utilcode.util.ToastUtils
import com.sx.mvvmlibs.base.BaseViewModel
import com.sx.mvvmlibs.bus.RxBus
import com.sx.mvvmlibs.http.CommonObserver
import com.sx.mvvmlibs.utils.RxThreadHelper
import com.sx.pipeline.app.event.ProductEvent
import com.sx.pipeline.app.model.CYBaseViewModel
import com.sx.pipeline.utils.AndroidUtil

class ChatReportVM(app: Application) : CYBaseViewModel(app) {
    var contentLiveData = MutableLiveData<String>()
    fun reqReport(type: Int,id: String, image:List<String>){
        var imageReq=AndroidUtil.listToString(image).toString()
        addSubscribe(
            mModel.report(type,contentLiveData.value.orEmpty(),id,imageReq)
                .compose(RxThreadHelper.rxSchedulerHelper())
                .subscribeWith(object : CommonObserver<Any, BaseViewModel<*>>
                    (this, true) {

                    override fun onResult(result: Any) {
                        ToastUtils.showShort("举报成功")
                        finish()
                    }

                    override fun onFailed(code: Int, msg: String?) {
                        super.onFailed(code, msg)
                        ToastUtils.showShort("$msg")

                    }
                })
        )
    }
}